package com.sooncode.project.focusservice.controller;

import com.sooncode.project.core.finder.Page;
import com.sooncode.project.focusservice._.base.Utils;
import com.sooncode.project.focusservice.model.Fee;
import com.sooncode.project.focusservice.service.FeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("fee")
public class FeeController {
    @Autowired
    FeeService service;

    @PostMapping("fee")
    public boolean add(@RequestParam Map map){
        return service.add(map);
    }
    @PutMapping("fee")
    public boolean modify(@RequestParam String id,@RequestParam Map map){
        return service.modify(id,map);
    }
    @DeleteMapping("fee")
    public boolean delete(@RequestParam String[] ids){
        for (String id:ids){
            service.delete(id);
        }
        return true;
    }
    @GetMapping("fees")
    public Page<Fee> getPageList(@RequestParam String memberId,@RequestParam int pageSize,@RequestParam int pageIndex,@RequestParam Map map) {
        map.remove("pageSize");
        map.remove("pageIndex");
        map.remove("memberId");
        Utils.mapValueTrim(map);
        return service.getPageList(memberId,pageSize, pageIndex-1, map);
    }
}
